#!/usr/bin/env python
from misc.utility.scons_hints import *

from glob import glob

import platform_builders

Import("env")

env.platform_sources = []


# Generate export icons
for platform in env.platform_exporters:
    for path in glob(f"{platform}/export/*.svg"):
        env.CommandNoCache(path.replace(".svg", "_svg.gen.h"), path, env.Run(platform_builders.export_icon_builder))


# Register platform-exclusive APIs
register_platform_apis = env.CommandNoCache(
    "register_platform_apis.gen.cpp",
    env.Value(env.platform_apis),
    env.Run(platform_builders.register_platform_apis_builder),
)
env.add_source_files(env.platform_sources, register_platform_apis)
for platform in env.platform_apis:
    env.add_source_files(env.platform_sources, f"{platform}/api/*.cpp")

lib = env.add_library("platform", env.platform_sources)
env.Prepend(LIBS=[lib])
